﻿/**
 * 该模块中的方法用来从获取各种信息
 */

//通过手机号码获取客户信息
function getKehuxxByShoujihm(shoujihm) {
	var kehuxx = '';
	$.ajax({
		url:path+'/yonghu/getKehuxxByShoujihm',
		type:'POST',
		async:false,
		data:{shoujihm:shoujihm},
		success:function(data) {
			kehuxx = data;
		}
	});
	return kehuxx;
}

//获得医疗机构编号
function getYiliaojgbh(){
	var yiliaojgbh = '';
	$.ajax({
		url:path+'/base/getDangqianzs',
		type:'POST',
		async:false,
		success:function(data) {
			if(data != '') {
				yiliaojgbh = data.yiliaojgbh;
			}
		}
	});
	return yiliaojgbh;
}

// 获取当前诊所的名称
function getZhensuomc(){
	var zhensuomc = '';
	$.ajax({
		url:path+'/base/getDangqianzs',
		type:'POST',
		async:false,
		success:function(data) {
			if(data != '') {
				zhensuomc = data.mingcheng;
			}
		}
	});
	return zhensuomc;
}

//获取当前诊所
function getZhensuoxx(){
	var zhensuoxx;
	$.ajax({
		url:path+'/base/getDangqianzs',
		type:'POST',
		async:false,
		success:function(data) {
			if(data != '') {
				zhensuoxx = data;
			}
		}
	});
	return zhensuoxx;
}

//获取当前诊所
function getHuanzheById(id){
	var huanzhe;
	$.ajax({
		url:path+'/huanzhe/getHuanzheById',
		type:'POST',
		data:{id:id},
		async:false,
		success:function(data) {
			if(data != '') {
				huanzhe = data.huanzhexx;
			}
		}
	});
	return huanzhe;
}

//获取登录员工
function getDengluyg(){
	var xingming = '';
	$.ajax({
		url:path+'/base/getDengluyg',
		type:'POST',
		async:false,
		success:function(data) {
			if(data != '') {
				xingming = data.xingming;
			}
		}
	});
	return xingming;
}

//根据剂型二级代码值获取二级代码名称
function getJixingByDmz(daimaz) {
	var jixing = '';
	$.ajax({
		url:path+'/yibaomldz/getErjidmByLbmcAndDmz',
		type:'POST',
		async:false,
		data:{leibiemc:'剂型',daimaz:daimaz},
		success:function(data) {
			if(data != '') {
				jixing = data;
			}
		}
	});
	return jixing;
}

//根据剂型二级代码名称获取二级代码名称
function getJixingByDmmc(obj) {
	var mingcheng = obj.val();
	$.ajax({
		url:path+'/zidian/getYibaojx',
		type:'POST',
		//async:false,
		data:{mingcheng:mingcheng},
		success:function(data) {
			if(data != '') {
				var str = '';
				$(data).each(function(){
					str += '<li>'+this.daimamc+'</li>'
				});
				$(obj).parent().find('ul').html("");
				$(obj).parent().find('ul').append(str);
			}
		}
	});
	return jixing;
}

// 打印处方
function printChufang(jiuzhenjlid,obj) {
	$.ajax({
	    type:"get",
	    //获取json文件路径
	    url:path+"/changguimz/getById",
	    //传送数据
	    data:{id:jiuzhenjlid},
	    async:false,
	    //请求成功完成后要执行的方法
	    success: function(data){
	    	if(data!='') {
	    		var huanzhexx = data.huanzhexx;
	    		var xingbie = '';
	    		if(huanzhexx.xingbie==1) {
	    			xingbie = '男'
	    		}else if(huanzhexx.xingbie==2){
	    			xingbie = '女';
	    		}
	    		var nianling = huanzhexx.nianling;
	    		if(nianling!=null) {
	    			nianling += huanzhexx.nianlingdw;
	    		}else{
	    			nianling = '';
	    		}
	    		
	    		var zsJiuzhenzds = data.zsJiuzhenzds;//诊断
	    		var zdStr = '';
	    		$(zsJiuzhenzds).each(function(i,e){
	    			if(i == 0) {
	    				zdStr += this.jibingmc;
	    			}else{
	    				zdStr += ',' +this.jibingmc;
	    			}
	    		});
	    		var exZsChengyaocfs = data.exZsChengyaocfs;
	    		if(exZsChengyaocfs!="") {
	    			$(exZsChengyaocfs).each(function(){
	    				var zsChengyaocf = this.zsChengyaocf;
	    				var printStr = '';
	    				printStr += '<div class="chengyaoxp" style="width:255mm;min-height:148mm;margin:0 5mm;font-family:Microsoft songti,Serif;">'+
	    			  	'<div class="chengyaoxp-main" style="min-height:148mm;padding:5mm;border:1px solid;">'+
	    				  	'<div class="chengyxpm-header" style="text-align: center;margin-bottom:5mm;margin-top:3mm;">'+
	    				  		'<span style="font-size:10mm;font-family:Microsoft songti,Serif;">'+getZhensuomc()+'</span>'+
	    				  		'<span style="float:right;border:1px solid;font-size:6mm;display:inline-block;padding:0 4mm;font-family:Microsoft songti,Serif;">成药方</span>'+
	    				  	'</div>'+
	    				  	'<div class="chengyxpm-baseinfo" style="border-bottom:1px solid;line-height:10mm">'+
	    				  		'<div class="chengyxpm-bif-row1" style="font-size:5mm;font-family:Microsoft songti,Serif;">'+
	    				  			'<span class="chengyxpm-bif-name" style="display:inline-block;margin-right:10mm;font-family:Microsoft songti,Serif;">姓名：<span style="font-family:Microsoft songti,Serif;">'+huanzhexx.xingming+'</span></span>'+
	    				  			'<span class="chengyxpm-bif-sex" style="margin-right:10mm;font-family:Microsoft songti,Serif;">性别：<span style="font-family:Microsoft songti,Serif;">'+xingbie+'</span></span>'+
	    				  			'<span class="chengyxpm-bif-age" style="margin-right:10mm;font-family:Microsoft songti,Serif;">年龄：<span style="font-family:Microsoft songti,Serif;">'+nianling+'</span></span>'+
	    				  			'<span class="chengyxpm-bif-date" style="font-family:Microsoft songti,Serif;">就诊日期：<span style="font-family:Microsoft songti,Serif;">'+formatDate(data.zsJiuzhenjl.jiuzhensj,true)+'</span></span>'+
	    				  		'</div>'+
	    				  		'<div class="chengyxpm-bif-row2" style="font-size:5mm;margin-bottom:3mm;font-family:Microsoft songti,Serif;">'+
	    				  			'<span class="chengyxpm-bif-zhend" style="font-family:Microsoft songti,Serif;">诊断：<span style="font-family:Microsoft songti,Serif;">'+zdStr+'</span></span>'+
	    				  			'<span class="chengyxpm-bif-danhao" style="float:right;font-weight:600;font-family:Microsoft songti,Serif;">No：<span style="font-family:Microsoft songti,Serif;">'+zsChengyaocf.id+'</span></span>'+
	    				  		'</div>'+
	    				  	'</div>'+
	    				  	'<div class="chengyxpm-table" style="min-height:100mm;font-family:Microsoft songti,Serif;">'+
	    				  		'<div class="chengyxpm-table-rp" style="font-weight:600;font-size:13mm;margin-top:0 0 5mm 0;font-family:Microsoft songti,Serif;">RP</div>'+
	    				  		'<table style="width:100%;margin-bottom:5mm;font-family:Microsoft songti,Serif;">'+
	    				  			'<tbody>';
				    				var yaopins = this.exYaopins;
				    				$(yaopins).each(function(){
				    					printStr += '<tr>'+
					  					'<th style="font-weight:500;font-family:Microsoft songti,Serif;text-align:left;width:50%">'+this.yaopinmc+'</th>'+
					  					'<td style="font-family:Microsoft songti,Serif;">'+this.yongyaopl+'</td>'+
					  					'<td style="font-family:Microsoft songti,Serif;">每次'+this.dancijl+this.dancijldw+'</td>'+
					  					'<td style="font-family:Microsoft songti,Serif;">'+this.yongfa+'</td>'+
					  					'<td style="font-family:Microsoft songti,Serif;">共'+this.kaiyaoliang+this.kaiyaodw+'</td>'+
					  				'</tr>';
				    				});
	    				printStr +='</tbody>'+
	    				  		'</table>'+
	    				  		'<div class="chengyxpm-blank" style="text-align:center;font-size:5mm;font-family:Microsoft songti,Serif;">'+
	    				  		'(以下空白)'+
	    				  		'</div>'+
	    				  	'</div>'+
	    				  	'<div class="chengyxpm-singer" style="float:right;line-height:8mm;font-size:8mm;font-weight:bold;font-family:Microsoft songti,Serif;">'+
	    				  		'医师（签章）_________'+
	    				  	'</div>'+
	    				  	'<div style="clear:both;"></div>'+
	    				  '</div>'+
	    				  '<div class="chengyxp-footer" style="margin-left:5mm;text-align:center;font-size:5mm;margin-top:5mm;font-family:Microsoft songti,Serif;">'+
	    				  	'<span class="chengyxp-footer-shenhe" style="float:left;font-family:Microsoft songti,Serif;">审核/调配：</span>'+
	    				  	'<span class="chengyxp-footer-hedui" style="font-family:Microsoft songti,Serif;">核对/发药：</span>'+
	    				  	'<span class="chengyxp-footer-shenhe" style="float:right;font-family:Microsoft songti,Serif;">打印时间：<span style="font-family:Microsoft songti,Serif;">'+formatDate(new Date().getTime(),false)+'</span></span>'+
	    				 '</div>'+
	    			  '</div>';
	    			obj.printArea(printStr); 
	    			});
	    		}
	    		
	    		var exZsCaoyaocfs = data.exZsCaoyaocfs;
	    		if(exZsCaoyaocfs!="") {
	    			var nianling = huanzhexx.nianling;
		    		if(nianling!=null) {
		    			nianling += huanzhexx.nianlingdw;
		    		}else{
		    			nianling = '';
		    		}
	    			$(exZsCaoyaocfs).each(function(){
	    				var zsCaoyaocf = this.zsCaoyaocf;
	    				var printStr = '';
	    				printStr += '<div class="chengyaoxp" style="width:255mm;min-height:148mm;margin:0 5mm;">'+
	    			  				'<div class="chengyaoxp-main" style="min-height:148mm;padding:5mm;border:1px solid;">'+
			    				  	'<div class="chengyxpm-header" style="text-align: center;margin-bottom:5mm;margin-top:3mm;font-family:Microsoft songti,Serif;">'+
			    				  		'<span style="font-size:10mm;font-weight:600;font-family:Microsoft songti,Serif;">'+getZhensuomc()+'</span>'+
			    				  		'<span style="float:right;border:1px solid;font-size:6mm;padding:0 4mm;font-family:Microsoft songti,Serif;">草药方</span>'+
			    				  	'</div>'+
    				  	'<div class="chengyxpm-baseinfo" style="border-bottom:1px solid;line-height:10mm">'+
    				  		'<div class="chengyxpm-bif-row1" style="font-size:5mm;font-family:Microsoft songti,Serif;">'+
    				  			'<span class="chengyxpm-bif-name" style="display:inline-block;margin-right:10mm;font-family:Microsoft songti,Serif;">姓名：<span style="font-family:Microsoft songti,Serif;">'+huanzhexx.xingming+'</span></span>'+
    				  			'<span class="chengyxpm-bif-sex" style="margin-right:10mm;font-family:Microsoft songti,Serif;">性别：<span style="font-family:Microsoft songti,Serif;">'+xingbie+'</span></span>'+
    				  			'<span class="chengyxpm-bif-age" style="margin-right:10mm;font-family:Microsoft songti,Serif;">年龄：<span style="font-family:Microsoft songti,Serif;">'+nianling+'</span></span>'+
    				  			'<span class="chengyxpm-bif-date" style="font-family:Microsoft songti,Serif;">就诊日期：<span style="font-family:Microsoft songti,Serif;">'+formatDate(data.zsJiuzhenjl.jiuzhensj,true)+'</span></span>'+
    				  		'</div>'+
    				  		'<div class="chengyxpm-bif-row2" style="font-size:5mm;font-family:Microsoft songti,Serif;margin-bottom:3mm;">'+
    				  			'<span class="chengyxpm-bif-zhend"style="font-family:Microsoft songti,Serif;">诊断：<span style="font-family:Microsoft songti,Serif;">'+zdStr+'</span></span>'+
    				  			'<span class="chengyxpm-bif-danhao" style="float:right;font-weight:600;font-family:Microsoft songti,Serif;">No：<span style="font-family:Microsoft songti,Serif;">'+zsCaoyaocf.id+'</span></span>'+
    				  		'</div>'+
    				  	'</div>'+
					  	'<div class="chengyxpm-table" style="min-height:100mm">'+
					  		'<div class="chengyxpm-table-rp" style="font-weight:900;font-size:13mm;font-family:Microsoft songti,Serif;">RP</div>'+
					  		'<div style="font-size:5mm;font-family:Microsoft songti,Serif;margin-bottom:3mm;">'+
					  			'<span style="margin-right:8mm;font-family:Microsoft songti,Serif;">剂数：<span style="font-family:Microsoft songti,Serif;">'+zsCaoyaocf.tieshu+'</span></span>'+
					  			'<span style="margin-right:8mm;font-family:Microsoft songti,Serif;">每日剂数：<span style="font-family:Microsoft songti,Serif;">'+zsCaoyaocf.meirijl+'</span></span> '+
					  			'<span style="margin-right:8mm;font-family:Microsoft songti,Serif;">'+zsCaoyaocf.yongyaopl+'</span>'+
					  			'<span style="margin-right:8mm;font-family:Microsoft songti,Serif;">'+zsCaoyaocf.yongfa+'</span>'+
					  		'</div>'+
					  		'<div style="font-size:5mm;font-family:Microsoft songti,Serif;">';
						  		var yaopins = this.exYaopins;
			    				$(yaopins).each(function(i,m){
			    					if(this.beizhu==""){
			    						printStr += '<span style="font-family:Microsoft songti,Serif;margin-bottom:2mm;margin-right:15px;line-height:35px;">'+this.yaopinmc+'<span style="font-size:4mm;font-weight:900">'+this.danjiliang+this.danwei+'</span></span>';
			    					}else {
			    						printStr += '<span style="font-family:Microsoft songti,Serif;margin-bottom:2mm;margin-right:15px;line-height:35px;">'+this.yaopinmc+'('+this.beizhu+')<span style="font-size:4mm;font-weight:900">'+this.danjiliang+this.danwei+'</span></span>';
			    					}
			    				});
			    			printStr +='</div>'+
			     			'<div class="chengyxpm-blank" style="text-align:right;font-size:5mm;font-family:Microsoft songti,Serif;">共<span style="font-family:Microsoft songti,Serif;">'+yaopins.length+'</span>味药</div>'+
					  		'<div class="chengyxpm-blank" style="text-align:center;font-size:5mm;font-family:Microsoft songti,Serif;">'+
					  		'(以下空白)'+
					  		'</div>'+
					  	'</div>'+
					  	'<div class="chengyxpm-singer" style="float:right;line-height:8mm;font-weight:bold;font-size:8mm;font-family:Microsoft songti,Serif;">医师（签章）_________</div>'+
					  	'<div style="clear:both;"></div>'+
					  '</div>'+
					  '<div class="chengyxp-footer" style="margin-left:5mm;text-align:center;font-size:5mm;font-family:Microsoft songti,Serif;margin-top:5mm;">'+
					  	'<span class="chengyxp-footer-shenhe" style="float:left;font-family:Microsoft songti,Serif;">审核/调配：</span>'+
					  	'<span class="chengyxp-footer-hedui" style="font-family:Microsoft songti,Serif;">核对/发药：</span>'+
					  	'<span class="chengyxp-footer-shenhe" style="float:right;font-family:Microsoft songti,Serif;">打印时间：<span style="font-family:Microsoft songti,Serif;"> '+formatDate(new Date().getTime(),false)+'</span></span>'+
					  '</div>'+
				 '</div>';
	    			obj.printArea(printStr); 
	    			});
	    		}
	    	}
	    	
	    }
	});
}

function printChufangYouZhuSu(jiuzhenjlid,obj) {
	$.ajax({
	    type:"get",
	    //获取json文件路径
	    url:path+"/changguimz/getById",
	    //传送数据
	    data:{id:jiuzhenjlid},
	    async:false,
	    //请求成功完成后要执行的方法
	    success: function(data){
	    	if(data!='') {
	    		var huanzhexx = data.huanzhexx;
	    		var xingbie = '';
	    		if(huanzhexx.xingbie==1) {
	    			xingbie = '男'
	    		}else if(huanzhexx.xingbie==2){
	    			xingbie = '女';
	    		}
	    		var nianling = huanzhexx.nianling;
	    		if(nianling!=null) {
	    			nianling += huanzhexx.nianlingdw;
	    		}else{
	    			nianling = '';
	    		}
	    		
	    		var zsJiuzhenzds = data.zsJiuzhenzds;//诊断
	    		var zdStr = '';
	    		$(zsJiuzhenzds).each(function(i,e){
	    			if(i == 0) {
	    				zdStr += this.jibingmc;
	    			}else{
	    				zdStr += ',' +this.jibingmc;
	    			}
	    		});
	    		var exZsChengyaocfs = data.exZsChengyaocfs;
	    		if(exZsChengyaocfs!="") {
	    			$(exZsChengyaocfs).each(function(){
	    				var zsChengyaocf = this.zsChengyaocf;
	    				var printStr = '';
	    				printStr += '<div class="chengyaoxp" style="width:255mm;min-height:148mm;margin:0 5mm;font-family:Microsoft songti,Serif;">'+
	    			  	'<div class="chengyaoxp-main" style="min-height:148mm;padding:5mm;border:1px solid;">'+
	    				  	'<div class="chengyxpm-header" style="text-align: center;margin-bottom:5mm;margin-top:3mm;">'+
	    				  		'<span style="font-size:10mm;font-family:Microsoft songti,Serif;">'+getZhensuomc()+'</span>'+
	    				  		'<span style="float:right;border:1px solid;font-size:6mm;display:inline-block;padding:0 4mm;font-family:Microsoft songti,Serif;">成药方</span>'+
	    				  	'</div>'+
	    				  	'<div class="chengyxpm-baseinfo" style="border-bottom:1px solid;line-height:10mm">'+
	    				  		'<div class="chengyxpm-bif-row1" style="font-size:5mm;font-family:Microsoft songti,Serif;">'+
	    				  			'<span class="chengyxpm-bif-name" style="display:inline-block;margin-right:10mm;font-family:Microsoft songti,Serif;">姓名：<span style="font-family:Microsoft songti,Serif;">'+huanzhexx.xingming+'</span></span>'+
	    				  			'<span class="chengyxpm-bif-sex" style="margin-right:10mm;font-family:Microsoft songti,Serif;">性别：<span style="font-family:Microsoft songti,Serif;">'+xingbie+'</span></span>'+
	    				  			'<span class="chengyxpm-bif-age" style="margin-right:10mm;font-family:Microsoft songti,Serif;">年龄：<span style="font-family:Microsoft songti,Serif;">'+nianling+'</span></span>'+
	    				  			'<span class="chengyxpm-bif-date" style="font-family:Microsoft songti,Serif;">就诊日期：<span style="font-family:Microsoft songti,Serif;">'+formatDate(data.zsJiuzhenjl.jiuzhensj,true)+'</span></span>'+
	    				  		'</div>'+
	    				  		'<div class="chengyxpm-bif-row2" style="font-size:5mm;font-family:Microsoft songti,Serif;">'+
	    				  			'<span class="chengyxpm-bif-zhend" style="font-family:Microsoft songti,Serif;">主诉：<span style="font-family:Microsoft songti,Serif;word-wrap:break-word;word-break:break-all;">'+common_util.nullToEmpty(data.zsJiuzhenjl.zhushu)+'</span></span>'+
	    				  		'</div>'+
	    				  		'<div class="chengyxpm-bif-row2" style="font-size:5mm;margin-bottom:3mm;font-family:Microsoft songti,Serif;">'+
	    				  			'<span class="chengyxpm-bif-zhend" style="font-family:Microsoft songti,Serif;">诊断：<span style="font-family:Microsoft songti,Serif;">'+zdStr+'</span></span>'+
	    				  			'<span class="chengyxpm-bif-danhao" style="float:right;font-weight:600;font-family:Microsoft songti,Serif;">No：<span style="font-family:Microsoft songti,Serif;">'+zsChengyaocf.id+'</span></span>'+
	    				  		'</div>'+
	    				  	'</div>'+
	    				  	'<div class="chengyxpm-table" style="min-height:100mm;font-family:Microsoft songti,Serif;">'+
	    				  		'<div class="chengyxpm-table-rp" style="font-weight:600;font-size:13mm;margin-top:0 0 5mm 0;font-family:Microsoft songti,Serif;">RP</div>'+
	    				  		'<table style="width:100%;margin-bottom:5mm;font-family:Microsoft songti,Serif;">'+
	    				  			'<tbody>';
				    				var yaopins = this.exYaopins;
				    				$(yaopins).each(function(){
				    					printStr += '<tr>'+
					  					'<th style="font-weight:500;font-family:Microsoft songti,Serif;text-align:left;width:50%">'+this.yaopinmc+'</th>'+
					  					'<td style="font-family:Microsoft songti,Serif;">'+this.yongyaopl+'</td>'+
					  					'<td style="font-family:Microsoft songti,Serif;">每次'+this.dancijl+this.dancijldw+'</td>'+
					  					'<td style="font-family:Microsoft songti,Serif;">'+this.yongfa+'</td>'+
					  					'<td style="font-family:Microsoft songti,Serif;">共'+this.kaiyaoliang+this.kaiyaodw+'</td>'+
					  				'</tr>';
				    				});
	    				printStr +='</tbody>'+
	    				  		'</table>'+
	    				  		'<div class="chengyxpm-blank" style="text-align:center;font-size:5mm;font-family:Microsoft songti,Serif;">'+
	    				  		'(以下空白)'+
	    				  		'</div>'+
	    				  	'</div>'+
	    				  	'<div class="chengyxpm-singer" style="float:right;line-height:8mm;font-size:8mm;font-weight:bold;font-family:Microsoft songti,Serif;">'+
	    				  		'医师（签章）_________'+
	    				  	'</div>'+
	    				  	'<div style="clear:both;"></div>'+
	    				  '</div>'+
	    				  '<div class="chengyxp-footer" style="margin-left:5mm;text-align:center;font-size:5mm;margin-top:5mm;font-family:Microsoft songti,Serif;">'+
	    				  	'<span class="chengyxp-footer-shenhe" style="float:left;font-family:Microsoft songti,Serif;">审核/调配：</span>'+
	    				  	'<span class="chengyxp-footer-hedui" style="font-family:Microsoft songti,Serif;">核对/发药：</span>'+
	    				  	'<span class="chengyxp-footer-shenhe" style="float:right;font-family:Microsoft songti,Serif;">打印时间：<span style="font-family:Microsoft songti,Serif;">'+formatDate(new Date().getTime(),false)+'</span></span>'+
	    				 '</div>'+
	    			  '</div>';
	    			obj.printArea(printStr); 
	    			});
	    		}
	    		
	    		var exZsCaoyaocfs = data.exZsCaoyaocfs;
	    		if(exZsCaoyaocfs!="") {
	    			var nianling = huanzhexx.nianling;
		    		if(nianling!=null) {
		    			nianling += huanzhexx.nianlingdw;
		    		}else{
		    			nianling = '';
		    		}
	    			$(exZsCaoyaocfs).each(function(){
	    				var zsCaoyaocf = this.zsCaoyaocf;
	    				var printStr = '';
	    				printStr += '<div class="chengyaoxp" style="width:255mm;min-height:148mm;margin:0 5mm;">'+
	    			  				'<div class="chengyaoxp-main" style="min-height:148mm;padding:5mm;border:1px solid;">'+
			    				  	'<div class="chengyxpm-header" style="text-align: center;margin-bottom:5mm;margin-top:3mm;font-family:Microsoft songti,Serif;">'+
			    				  		'<span style="font-size:10mm;font-weight:600;font-family:Microsoft songti,Serif;">'+getZhensuomc()+'</span>'+
			    				  		'<span style="float:right;border:1px solid;font-size:6mm;padding:0 4mm;font-family:Microsoft songti,Serif;">草药方</span>'+
			    				  	'</div>'+
    				  	'<div class="chengyxpm-baseinfo" style="border-bottom:1px solid;line-height:10mm">'+
    				  		'<div class="chengyxpm-bif-row1" style="font-size:5mm;font-family:Microsoft songti,Serif;">'+
    				  			'<span class="chengyxpm-bif-name" style="display:inline-block;margin-right:10mm;font-family:Microsoft songti,Serif;">姓名：<span style="font-family:Microsoft songti,Serif;">'+huanzhexx.xingming+'</span></span>'+
    				  			'<span class="chengyxpm-bif-sex" style="margin-right:10mm;font-family:Microsoft songti,Serif;">性别：<span style="font-family:Microsoft songti,Serif;">'+xingbie+'</span></span>'+
    				  			'<span class="chengyxpm-bif-age" style="margin-right:10mm;font-family:Microsoft songti,Serif;">年龄：<span style="font-family:Microsoft songti,Serif;">'+nianling+'</span></span>'+
    				  			'<span class="chengyxpm-bif-date" style="font-family:Microsoft songti,Serif;">就诊日期：<span style="font-family:Microsoft songti,Serif;">'+formatDate(data.zsJiuzhenjl.jiuzhensj,true)+'</span></span>'+
    				  		'</div>'+
    				  		'<div class="chengyxpm-bif-row2" style="font-size:5mm;font-family:Microsoft songti,Serif;">'+
					  			'<span class="chengyxpm-bif-zhend"style="font-family:Microsoft songti,Serif;">主诉：<span style="font-family:Microsoft songti,Serif;word-wrap:break-word;word-break:break-all;">'+common_util.nullToEmpty(data.zsJiuzhenjl.zhushu)+'</span></span>'+
					  		'</div>'+
    				  		'<div class="chengyxpm-bif-row2" style="font-size:5mm;font-family:Microsoft songti,Serif;margin-bottom:3mm;">'+
    				  			'<span class="chengyxpm-bif-zhend"style="font-family:Microsoft songti,Serif;">诊断：<span style="font-family:Microsoft songti,Serif;">'+zdStr+'</span></span>'+
    				  			'<span class="chengyxpm-bif-danhao" style="float:right;font-weight:600;font-family:Microsoft songti,Serif;">No：<span style="font-family:Microsoft songti,Serif;">'+zsCaoyaocf.id+'</span></span>'+
    				  		'</div>'+
    				  	'</div>'+
					  	'<div class="chengyxpm-table" style="min-height:100mm">'+
					  		'<div class="chengyxpm-table-rp" style="font-weight:900;font-size:13mm;font-family:Microsoft songti,Serif;">RP</div>'+
					  		'<div style="font-size:5mm;font-family:Microsoft songti,Serif;margin-bottom:3mm;">'+
					  			'<span style="margin-right:8mm;font-family:Microsoft songti,Serif;">剂数：<span style="font-family:Microsoft songti,Serif;">'+zsCaoyaocf.tieshu+'</span></span>'+
					  			'<span style="margin-right:8mm;font-family:Microsoft songti,Serif;">每日剂数：<span style="font-family:Microsoft songti,Serif;">'+zsCaoyaocf.meirijl+'</span></span> '+
					  			'<span style="margin-right:8mm;font-family:Microsoft songti,Serif;">'+zsCaoyaocf.yongyaopl+'</span>'+
					  			'<span style="margin-right:8mm;font-family:Microsoft songti,Serif;">'+zsCaoyaocf.yongfa+'</span>'+
					  		'</div>'+
					  		'<div style="font-size:5mm;font-family:Microsoft songti,Serif;">';
						  		var yaopins = this.exYaopins;
			    				$(yaopins).each(function(i,m){
			    					if(this.beizhu==""){
			    						printStr += '<span style="font-family:Microsoft songti,Serif;margin-bottom:2mm;margin-right:15px;line-height:35px;">'+this.yaopinmc+'<span style="font-size:4mm;font-weight:900">'+this.danjiliang+this.danwei+'</span></span>';
			    					}else {
			    						printStr += '<span style="font-family:Microsoft songti,Serif;margin-bottom:2mm;margin-right:15px;line-height:35px;">'+this.yaopinmc+'('+this.beizhu+')<span style="font-size:4mm;font-weight:900">'+this.danjiliang+this.danwei+'</span></span>';
			    					}
			    				});
			    			printStr +='</div>'+
			     			'<div class="chengyxpm-blank" style="text-align:right;font-size:5mm;font-family:Microsoft songti,Serif;">共<span style="font-family:Microsoft songti,Serif;">'+yaopins.length+'</span>味药</div>'+
					  		'<div class="chengyxpm-blank" style="text-align:center;font-size:5mm;font-family:Microsoft songti,Serif;">'+
					  		'(以下空白)'+
					  		'</div>'+
					  	'</div>'+
					  	'<div class="chengyxpm-singer" style="float:right;line-height:8mm;font-weight:bold;font-size:8mm;font-family:Microsoft songti,Serif;">医师（签章）_________</div>'+
					  	'<div style="clear:both;"></div>'+
					  '</div>'+
					  '<div class="chengyxp-footer" style="margin-left:5mm;text-align:center;font-size:5mm;font-family:Microsoft songti,Serif;margin-top:5mm;">'+
					  	'<span class="chengyxp-footer-shenhe" style="float:left;font-family:Microsoft songti,Serif;">审核/调配：</span>'+
					  	'<span class="chengyxp-footer-hedui" style="font-family:Microsoft songti,Serif;">核对/发药：</span>'+
					  	'<span class="chengyxp-footer-shenhe" style="float:right;font-family:Microsoft songti,Serif;">打印时间：<span style="font-family:Microsoft songti,Serif;"> '+formatDate(new Date().getTime(),false)+'</span></span>'+
					  '</div>'+
				 '</div>';
	    			obj.printArea(printStr); 
	    			});
	    		}
	    	}
	    	
	    }
	});
}

// 打印小票
function printXiaopiaoMingXi(shoufeijlid,obj) {
	var printStr = '';
	$.ajax({
        type:"POST",
        url:path+"/chaxuntjsfjl/getById",
        data:{id:shoufeijlid},
        async:false,
        success: function(data){
        	if(data!='') {
        		var xingbie = data[0].xingbie;
				if(xingbie==1) {
					xingbie = '男';
				}else if(xingbie==2) {
					xingbie = '女';
				}else{
					xingbie = '';
				}
        		printStr += '<div class="xiaopiaody" id="dayinxp" style="width:72mm;text-align: center;font-size:24px;">'+
        	  	'<div class="xiaop-header" style="text-align:center;width:72mm;font-size:24px;font-weight:600;line-height:30px;padding-bottom:8px;">'+getZhensuomc()+'费用小票</div>'+
        	  	'<div class="xiaop-header" style="text-align:center;width:72mm;font-size:18px;font-weight:900;line-height:25px;padding-bottom:8px;display:none;">杭州市医保定点结算单</div>'+//医保信息块
        	  	'<div class="xiaop-baseinfo clearfix" style="padding-top:8px;width:72mm;font-weight:600;clear:both;font-size:18px;line-height:30px;display:block;">'+
        	  	'<span class="xiaopbf-name" style="float:left;font-weight:900;">销售凭证ID：<span>'+data[0].jiuzhenjlid+'</span></span>'+
        	  	'<span class="xiaopbf-name" style="float:left;font-weight:900;">就诊时间：<span>'+data[0].jiuzhensj+'</span></span>'+	
        	  	'<span class="xiaopbf-name" style="float:left;font-weight:900;">姓名：<span>'+data[0].xingming+'</span></span></div>';
				var nianling = data[0].nianling;
	    		if(nianling!=null) {
	    			nianling += data[0].nianlingdw;
	    		}else{
	    			nianling = '';
	    		}
	    		printStr +='<div class="xiaop-baseinfo clearfix" style="width:72mm;padding-bottom:8px;clear:both;font-size:18px;line-height:30px;display:block;border-bottom:1px dashed;padding-bottom:25px;">'+
        	  		'<span class="xiaopbf-sex" style="font-weight:500;float:left;">性别：<span>'+xingbie+'</span></span>'+
        	  		'<span class="xiaopbf-age" style="float:left;font-weight:500;margin-left:15px;">年龄：<span>'+nianling+'</span></span>'+
        	  		'<div style="clear:both"></div>'+
        	  	'</div>'+
        	  	'<div class="xiaop-yaopintable" style="width:72mm;text-align: center;border-bottom:1px dashed;font-size:20px;padding:25px 0;position: relative;">'+
        	  		'<div style="background-color:#fff;width:30mm;position: absolute;top:-10px;left:30%;font-size:18px;">费用明细</div>'+
        		  	'<table style="margin:auto ;width:100%;font-size:4mm;line-height:25px;table-layout: fixed;padding:8px 0;">'+
        		  		'<thead style="border-bottom:1px dashed;font-size:18px;">'+
        		  			'<tr style="line-height:25px;font-size:18px;">'+
        			  			'<th width="35%" style="font-weight:500;text-align: left;word-break:break-all">名称</th>'+
        			  			'<td width="15%">数量</td>'+
        			  			'<td width="25%" style="text-align:right;">单价/元</td>'+
        			  			'<td width="25%" style="text-align:right;">金额/元</td>'+
        			  		'</tr>'+
        		  		'</thead>'+
        		  		'<tbody>';
		        		$(data).each(function(){
		        			//单位判断是否为空
							if(this.danwei==null){
								var danwei='';
							}else{
								var danwei=this.danwei;
							}
		        			printStr += '<tr style="line-height:25px;font-size:18px;">'+
			  				'<th width="55%" style="font-weight:500;text-align: left;word-break:break-all">'+this.mingcheng+'</th>'+
			  				'<td width="15%">'+this.shuliang+danwei+'</td>'+
			  				'<td width="15%" style="text-align:right;">'+this.danjia.toFixed(2)+'</td>'+
			  				'<td width="15%" style="text-align:right;">'+this.zsmYingshouje.toFixed(2)+'</td>'+
			  				'</tr>';
		        		});
		        		printStr +='</tbody>'+
        		  	'</table>'+
        		'</div>'+
        		'<div class="yibaojs clearfix" style="border-bottom:1px dashed;width:72mm;position: relative;display:none;">'+//医保信息块
        			'<div style="background-color:#fff;width:30mm;position: absolute;top:-10px;left:30%;font-size:18px;">医保结算</div>'+
	        		'<ul style="padding:25px 0;margin:0;line-height:25px;font-sizw:18px;">'+
        				'<li style="list-style:none;text-align:left;padding:0;margin:0;line-height:25px;font-size:18px;">本年支付：<span></span></li>'+
        				'<li style="list-style:none;text-align:left;padding:0;margin:0;line-height:25px;font-size:18px;">本年余额：<span></span></li>'+
        				'<li style="list-style:none;text-align:left;padding:0;margin:0;line-height:25px;font-size:18px;">历年支付：<span></span></li>'+
        				'<li style="list-style:none;text-align:left;padding:0;margin:0;line-height:25px;font-size:18px;">历年余额：<span></span></li>'+
        				'<li style="list-style:none;text-align:left;padding:0;margin:0;line-height:25px;font-size:18px;">本次起付标准：<span></span></li>'+
        				'<li style="list-style:none;text-align:left;padding:0;margin:0;line-height:25px;font-size:18px;">起付标准累计：<span></span></li>'+
        				'<li style="list-style:none;text-align:left;padding:0;margin:0;line-height:25px;font-size:18px;">自理：<span></span></li>'+
        				'<li style="list-style:none;text-align:left;padding:0;margin:0;line-height:25px;font-size:18px;">自费：<span></span></li>'+
        				'<li style="list-style:none;text-align:left;padding:0;margin:0;line-height:25px;font-size:18px;">自负：<span></span></li>'+
        				'<li style="list-style:none;text-align:left;padding:0;margin:0;line-height:25px;font-size:18px;">(其中历年账户：2000.00)<span></span></li>'+
        				'<li style="list-style:none;text-align:left;padding:0;margin:0;line-height:25px;font-size:18px;">(其中历年账户：500.00)<span></span></li>'+
        				'<li style="list-style:none;text-align:left;padding:0;margin:0;line-height:25px;font-size:18px;">(其中历年账户：40.00)<span></span></li>'+
        			'</ul>'+
	        	'</div>'+
        	  	'<div class="xiaop-moneyinfo clearfix" style="width:72mm;padding-top:25px;position: relative;">'+
        	  		'<div style="background-color:#fff;width:30mm;position: absolute;top:-10px;left:30%;font-size:18px;">结算信息</div>'+
        	  		'<div class="xiaop-mif-left clearfix" style="float:left;text-align:left;font-size:18px;line-height:30px;padding:8px 0;">';
        			printStr +='<div class="xiaopmf-yingshou">合计：<span>'+data[0].yingshouje.toFixed(2)+'</span>元</div>';
        		if(data[0].zhehouje==null){
        			printStr +='<div class="xiaopmf-yingshou">应收：<span>0.00</span>元</div>';
        		}else{
        			printStr +='<div class="xiaopmf-yingshou">应收：<span>'+data[0].zhehouje.toFixed(2)+'</span>元</div>';
        		}
	  			var shifujine = parseFloat(data[0].zhehouje) + parseFloat(data[0].zhaolingje) - data[0].qianfeije;
	  			printStr +='<div class="xiaopmf-shishou">实付：<span>'+shifujine.toFixed(2)+'</span>元</div>';
	  			printStr +='</div>'+
        	  		'<div class="xiaop-mif-right clearfix" style="float:right;text-align:left;font-size:18px;line-height:30px;padding:8px 0;">';
	  				printStr +='<div class="xiaopmf-yingshou">优惠：<span>'+data[0].jianmianje.toFixed(2)+'</span>元</div>';
	  			if(data[0].zhaolingje==null){
    	  			printStr +='<div class="xiaopmf-zhaoling">找零：<span>0.00</span>元</div>';
        		}else{
        			printStr +='<div class="xiaopmf-zhaoling">找零：<span>'+data[0].zhaolingje.toFixed(2)+'</span>元</div>';
        		}
        		if(data[0].qianfeije==null){
        			printStr +='<div class="xiaopmf-qianfei" style="font-size:18px;">欠费：<span>0.00元</span></div>';
				}else{
					printStr +='<div class="xiaopmf-qianfei" style="font-size:18px;">欠费：<span>'+data[0].qianfeije.toFixed(2)+'</span>元</div>';
				}
        		printStr +='</div>'+
        	  		'<div style="clear:both"></div>'+
        	  	'</div>'+
        	  	'<div class="xiaop-date clearfix" style="clear:both;font-size:20px;width:72mm;line-height:25px;display:block;">'+
        	  		'<span class="xiaopdt-riqi" style="float:left;font-size:20px;text-align: left;">时间：<span>'+data[0].shoufeisjstr+'</span></span><div style="clear:both"></div>'+
        	  	'<div class="xiaop-date clearfix" style="clear:both;font-size:20px;width:72mm;line-height:25px;margin:0;display:block;text-align: left;">'+
        	  		'<span class="xiaopdt-operator" style="margin:0;padding:0;float:left;text-align: left;font-size:20px;">收费员：<span>'+data[0].shoufeir+'</span></span>'+
        	  		'<div style="clear:both"></div>'+
        	  	'</div>'+
        	  	'<div class="xiaop-bless" style="text-align:center;font-size:20px;line-height:20px">祝您健康！</div>'+
        	  '</div>';
        	}
        }
	});
	obj.printArea(printStr); 
}

function printXiaopiao(shoufeijlid,obj) {
	var printStr = '';
	$.ajax({
        type:"POST",
        url:path+"/chaxuntjsfjl/getById",
        data:{id:shoufeijlid},
        async:false,
        success: function(data){
        	if(data!='') {
        		var xingbie = data[0].xingbie;
				if(xingbie==1) {
					xingbie = '男';
				}else if(xingbie==2) {
					xingbie = '女';
				}else{
					xingbie = '';
				}
        		printStr += '<div class="xiaopiaody" id="dayinxp" style="width:72mm;text-align: center;font-size:24px;">'+
        	  	'<div class="xiaop-header" style="text-align:center;width:72mm;font-size:24px;font-weight:600;line-height:30px;padding-bottom:8px;">'+getZhensuomc()+'费用小票</div>'+
        	  	'<div class="xiaop-header" style="text-align:center;width:72mm;font-size:18px;font-weight:900;line-height:25px;padding-bottom:8px;display:none;">杭州市医保定点结算单</div>'+//医保信息块
        	  	'<div class="xiaop-baseinfo clearfix" style="padding-top:8px;width:72mm;font-weight:600;clear:both;font-size:18px;line-height:30px;display:block;">'+
        	  	'<span class="xiaopbf-name" style="float:left;font-weight:900;">销售凭证ID：<span>'+data[0].jiuzhenjlid+'</span></span>'+
        	  	'<span class="xiaopbf-name" style="float:left;font-weight:900;">就诊时间：<span>'+data[0].jiuzhensj+'</span></span>'+	
        	  	'<span class="xiaopbf-name" style="float:left;font-weight:900;">姓名：<span>'+data[0].xingming+'</span></span></div>';
				var nianling = data[0].nianling;
	    		if(nianling!=null) {
	    			nianling += data[0].nianlingdw;
	    		}else{
	    			nianling = '';
	    		}
	    		printStr +='<div class="xiaop-baseinfo clearfix" style="width:72mm;padding-bottom:8px;clear:both;font-size:18px;line-height:30px;display:block;border-bottom:1px dashed;padding-bottom:25px;">'+
        	  		'<span class="xiaopbf-sex" style="font-weight:500;float:left;">性别：<span>'+xingbie+'</span></span>'+
        	  		'<span class="xiaopbf-age" style="float:left;font-weight:500;margin-left:15px;">年龄：<span>'+nianling+'</span></span>'+
        	  		'<div style="clear:both"></div>'+
        	  	'</div>'+
        	  	'<div class="xiaop-yaopintable" style="width:72mm;text-align: center;border-bottom:1px dashed;font-size:20px;padding:25px 0;position: relative;">'+
        	  		'<div style="background-color:#fff;width:30mm;position: absolute;top:-10px;left:30%;font-size:18px;">费用明细</div>'+
        		  	'<table style="margin:auto ;width:100%;font-size:4mm;line-height:25px;table-layout: fixed;padding:8px 0;">'+
        		  		'<thead style="border-bottom:1px dashed;font-size:18px;">'+
        		  			'<tr style="line-height:25px;font-size:18px;">'+
        			  			'<th width="35%" style="font-weight:500;text-align: left;word-break:break-all">费用类型</th>'+
        			  			'<td width="25%" style="text-align:right;">金额/元</td>'+
        			  		'</tr>'+
        		  		'</thead>'+
        		  		'<tbody>';
			    		var chengyaoje = 0;
						var caoyaoje = 0;
						var jinchaxje = 0;
						var fujiafje = 0;
						var haocaije = 0;
		        		$(data).each(function(){
		        			var leixing='';
		    				if(this.xiangmulx==1) {
		    					chengyaoje += parseFloat(this.zsmZhehouje);
		    				}else if(this.xiangmulx==2){
		    					caoyaoje += parseFloat(this.zsmZhehouje);
		    				}else if(this.xiangmulx==3){
		    					jinchaxje += parseFloat(this.zsmZhehouje);
		    				}else if(this.xiangmulx==4){
		    					fujiafje += parseFloat(this.zsmZhehouje);
		    				}else if(this.xiangmulx==5){
		    					haocaije += parseFloat(this.zsmZhehouje);
		    				}
		        		});
		        		if(!!chengyaoje) {
		        			printStr += '<tr style="line-height:25px;font-size:18px;">'+
			  				'<th width="55%" style="font-weight:500;text-align: left;word-break:break-all">成药</th>'+
			  				'<td width="15%" style="text-align:right;">'+chengyaoje.toFixed(2)+'</td>'+
			  				'</tr>';
		        		}
		        		if(!!caoyaoje) {
		        			printStr += '<tr style="line-height:25px;font-size:18px;">'+
			  				'<th width="55%" style="font-weight:500;text-align: left;word-break:break-all">草药</th>'+
			  				'<td width="15%" style="text-align:right;">'+caoyaoje.toFixed(2)+'</td>'+
			  				'</tr>';
		        		}
		        		if(!!jinchaxje) {
		        			printStr += '<tr style="line-height:25px;font-size:18px;">'+
			  				'<th width="55%" style="font-weight:500;text-align: left;word-break:break-all">诊疗项</th>'+
			  				'<td width="15%" style="text-align:right;">'+jinchaxje.toFixed(2)+'</td>'+
			  				'</tr>';
		        		}
		        		if(!!fujiafje) {
		        			printStr += '<tr style="line-height:25px;font-size:18px;">'+
			  				'<th width="55%" style="font-weight:500;text-align: left;word-break:break-all">附加费</th>'+
			  				'<td width="15%" style="text-align:right;">'+fujiafje.toFixed(2)+'</td>'+
			  				'</tr>';
		        		}
		        		if(!!haocaije) {
		        			printStr += '<tr style="line-height:25px;font-size:18px;">'+
			  				'<th width="55%" style="font-weight:500;text-align: left;word-break:break-all">耗材</th>'+
			  				'<td width="15%" style="text-align:right;">'+haocaije.toFixed(2)+'</td>'+
			  				'</tr>';
		        		}
		        		printStr +='</tbody>'+
        		  	'</table>'+
        		'</div>'+
        		'<div class="yibaojs clearfix" style="border-bottom:1px dashed;width:72mm;position: relative;display:none;">'+//医保信息块
        			'<div style="background-color:#fff;width:30mm;position: absolute;top:-10px;left:30%;font-size:18px;">医保结算</div>'+
	        		'<ul style="padding:25px 0;margin:0;line-height:25px;font-sizw:18px;">'+
        				'<li style="list-style:none;text-align:left;padding:0;margin:0;line-height:25px;font-size:18px;">本年支付：<span></span></li>'+
        				'<li style="list-style:none;text-align:left;padding:0;margin:0;line-height:25px;font-size:18px;">本年余额：<span></span></li>'+
        				'<li style="list-style:none;text-align:left;padding:0;margin:0;line-height:25px;font-size:18px;">历年支付：<span></span></li>'+
        				'<li style="list-style:none;text-align:left;padding:0;margin:0;line-height:25px;font-size:18px;">历年余额：<span></span></li>'+
        				'<li style="list-style:none;text-align:left;padding:0;margin:0;line-height:25px;font-size:18px;">本次起付标准：<span></span></li>'+
        				'<li style="list-style:none;text-align:left;padding:0;margin:0;line-height:25px;font-size:18px;">起付标准累计：<span></span></li>'+
        				'<li style="list-style:none;text-align:left;padding:0;margin:0;line-height:25px;font-size:18px;">自理：<span></span></li>'+
        				'<li style="list-style:none;text-align:left;padding:0;margin:0;line-height:25px;font-size:18px;">自费：<span></span></li>'+
        				'<li style="list-style:none;text-align:left;padding:0;margin:0;line-height:25px;font-size:18px;">自负：<span></span></li>'+
        				'<li style="list-style:none;text-align:left;padding:0;margin:0;line-height:25px;font-size:18px;">(其中历年账户：2000.00)<span></span></li>'+
        				'<li style="list-style:none;text-align:left;padding:0;margin:0;line-height:25px;font-size:18px;">(其中历年账户：500.00)<span></span></li>'+
        				'<li style="list-style:none;text-align:left;padding:0;margin:0;line-height:25px;font-size:18px;">(其中历年账户：40.00)<span></span></li>'+
        			'</ul>'+
	        	'</div>'+
        	  	'<div class="xiaop-moneyinfo clearfix" style="width:72mm;padding-top:25px;position: relative;">'+
        	  		'<div style="background-color:#fff;width:30mm;position: absolute;top:-10px;left:30%;font-size:18px;">结算信息</div>'+
        	  		'<div class="xiaop-mif-left clearfix" style="float:left;text-align:left;font-size:18px;line-height:30px;padding:8px 0;">';
        			printStr +='<div class="xiaopmf-yingshou">合计：<span>'+data[0].yingshouje.toFixed(2)+'</span>元</div>';
        		if(data[0].zhehouje==null){
        			printStr +='<div class="xiaopmf-yingshou">应收：<span>0.00</span>元</div>';
        		}else{
        			printStr +='<div class="xiaopmf-yingshou">应收：<span>'+data[0].zhehouje.toFixed(2)+'</span>元</div>';
        		}
	  			var shifujine = parseFloat(data[0].zhehouje) + parseFloat(data[0].zhaolingje) - data[0].qianfeije;
	  			printStr +='<div class="xiaopmf-shishou">实付：<span>'+shifujine.toFixed(2)+'</span>元</div>';
	  			printStr +='</div>'+
        	  		'<div class="xiaop-mif-right clearfix" style="float:right;text-align:left;font-size:18px;line-height:30px;padding:8px 0;">';
	  				printStr +='<div class="xiaopmf-yingshou">优惠：<span>'+data[0].jianmianje.toFixed(2)+'</span>元</div>';
	  			if(data[0].zhaolingje==null){
    	  			printStr +='<div class="xiaopmf-zhaoling">找零：<span>0.00</span>元</div>';
        		}else{
        			printStr +='<div class="xiaopmf-zhaoling">找零：<span>'+data[0].zhaolingje.toFixed(2)+'</span>元</div>';
        		}
        		if(data[0].qianfeije==null){
        			printStr +='<div class="xiaopmf-qianfei" style="font-size:18px;">欠费：<span>0.00元</span></div>';
				}else{
					printStr +='<div class="xiaopmf-qianfei" style="font-size:18px;">欠费：<span>'+data[0].qianfeije.toFixed(2)+'</span>元</div>';
				}
        		printStr +='</div>'+
        	  		'<div style="clear:both"></div>'+
        	  	'</div>'+
        	  	'<div class="xiaop-date clearfix" style="clear:both;font-size:20px;width:72mm;line-height:25px;display:block;">'+
        	  		'<span class="xiaopdt-riqi" style="float:left;font-size:20px;text-align: left;">时间：<span>'+data[0].shoufeisjstr+'</span></span><div style="clear:both"></div>'+
        	  	'<div class="xiaop-date clearfix" style="clear:both;font-size:20px;width:72mm;line-height:25px;margin:0;display:block;text-align: left;">'+
        	  		'<span class="xiaopdt-operator" style="margin:0;padding:0;float:left;text-align: left;font-size:20px;">收费员：<span>'+data[0].shoufeir+'</span></span>'+
        	  		'<div style="clear:both"></div>'+
        	  	'</div>'+
        	  	'<div class="xiaop-bless" style="text-align:center;font-size:20px;line-height:20px">祝您健康！</div>'+
        	  '</div>';
        	}
        }
	});
	obj.printArea(printStr); 
}

//医保发票===========================================勿删
function printFaPiaoxx(id,obj) {
    var fapiaoxq;
    var xiyaofei = '';
    var zhongyaofei = '';
    var jianchaxfy = '';
    var fujiafy = '';
    var haocaify = '';
    $.ajax({
        type: "get",
        url: path + "/shoufei/getYiBaofpxx",
        data: {"shoufeijlid": id},
        async: false,
        success: function (data) {
            fapiaoxq = data;
        }
    });
	if (fapiaoxq != null) {
		$.each(fapiaoxq.faPiaoxmhzs, function () {
	    	switch (this.xiangmulx) {
	    	case 1: xiyaofei = this.mxzonge.toFixed(2); break;
	    	case 2: zhongyaofei = this.mxzonge.toFixed(2); break;
	    	case 3: jianchaxfy = this.mxzonge.toFixed(2); break;
	    	case 4: fujiafy = this.mxzonge.toFixed(2); break;
	    	case 5: haocaify = this.mxzonge.toFixed(2); break;
	    	}
	    });
	}
	// 是否医保判断
	var yibaobz;
	if (fapiaoxq.yibaojsid == null) {
		yibaobz = "display:none";
	} else {
		yibaobz = "display:block";
	}
	var shijian = new Date(fapiaoxq.shijian);
	var Year = shijian.getFullYear();
	var Mon = shijian.getMonth()
	var Day = shijian.getDate();
	var printStr = '';
		printStr += '<div class="main-box clearfix" style="width:190mm;margin:0 auto;font-size:14px;">'+
						'<div class="left-feiyong" style="float:left;width:72mm;padding-top:20mm;">'+
							'<div class="yibaoxx kahao" style="padding-top:20mm;line-height:25px;display:none;margin-left:70px;"><span class="mingcheng"></span><span class="kahao" id="yibaokh" style="line-height:25px;">8686868686</span></div>'+
								'<div class="kahao" style="line-height:25px;margin-left:15px;">'+
									'<span class="mingcheng" style=""></span>'+fapiaoxq.xingming+'<span class="kahao" id="yibaoxm" style="line-height:25px;></span><span class="time" style="float:right;"><span class="nian jiange" style="display:inline-block;margin-left:2mm;">'+Year+'</span><span class="yue jiange" style="margin-left:15px;">'+(Mon + 1)+'</span><span class="ri jiange"  style="margin-left:15px;">'+Day+'</span></span></div>'+
								'<div class="table-list" style="">'+
									'<table width="100%" cellpadding="0" border="0" cellspacing="0" style="table-layout:fixed;border-collapse: collapse;">'+
										'<thead>'+
											'<tr style="line-height:25px;height:25px;">'+
												'<th></th>'+
												'<th></th>'+
												'<th></th>'+
												'<th></th>'+
											'</tr>'+
										'</thead>'+
										'<tbody>'+
											'<tr style="line-height:25px;height:25px;">'+
												'<td></td><td style="text-align:center;">'+xiyaofei+'</td><td></td><td style="text-align:center;"></td>'+
											'</tr>'+
											'<tr style="line-height:25px;height:25px;">'+
												'<td></td><td style="text-align:center;">'+zhongyaofei+'</td><td></td><td style="text-align:center;"></td>'+
											'</tr>'+
											'<tr style="line-height:25px;height:25px;">'+
												'<td></td><td style="text-align:center;"></td><td></td><td></td>'+
											'</tr>'+
											'<tr style="line-height:25px;height:25px;">'+
												'<td></td><td style="text-align:center;"></td><td></td><td style="text-align:center;"></td>'+
											'</tr>'+
											'<tr style="line-height:25px;height:25px;">'+
												'<td></td><td style="text-align:center;"></td><td></td><td style="text-align:center;"></td>'+
											'</tr>'+
											'<tr style="line-height:25px;height:25px;">'+
												'<td></td><td style="text-align:center;">'+jianchaxfy+'</td><td></td><td style="text-align:center;"></td>'+
											'</tr>'+
											'<tr style="line-height:25px;height:25px;">'+
												'<td></td><td></td><td></td><td style="text-align:center;">'+haocaify+'</td>'+
											'</tr>'+
											'<tr style="line-height:25px;height:25px;">'+
												'<td></td><td></td><td></td><td style="text-align:center;">'+fujiafy+'</td>'+
											'</tr>'+
											'<tr style="line-height:25px;height:25px;">'+
												'<td></td><td colspan="3" style="text-align: left;padding-left: 8px;">' + ChinaCost(fapiaoxq.hejije) + '</td>'+
											'</tr>'+
										'</tbody>'+
									'</table>'+
									'<div><span class="kahao" style="line-height:25px;height:25px;margin-left:80px;"></span><span>'+fapiaoxq.shoukuanr+'</span></div>'+
								'</div>'+
							'</div>'+
						'<div class="right-mingxi" style="width:110mm;float:left;margin-left:5mm;">'+
							'<div class="table-list" style="height:75mm;padding-top:9mm;">'+
								'<table class="wubiankuang" width="100%" cellpadding="0" border="0" cellspacing="0" style="table-layout: fixed;">'+
								'<thead>'+
									'<tr style="line-height:25px;height:25px;">'+
										'<th width="25%"></th>'+
										'<th width="8%" style="'+yibaobz+'"></th>'+
										'<th width="8%"></th>'+
										'<th width="10%"></th>'+
										'<th width="18%" style="'+yibaobz+'"></th>'+
									'</tr>'+
								'</thead>'+
								'<tbody>';
								if (fapiaoxq != null) {
									$.each(fapiaoxq.faPiaosfmxs, function (i, v) {
										if(i < 17){
											printStr += '<tr>'+
															'<td width="25%" class="left" style="font-size:10px;text-align:left;overflow: hidden;white-space: nowrap;">' + this.mingcheng + (this.guige || '')+'</td>'+
															'<td width="8%" style="font-size:10px;text-align:center;'+yibaobz+'" >'+(this.shoufeixmdj || '' )+ '</td>'+
															'<td width="8%" style="font-size:10px;text-align:center;">'+this.shuliang + (this.danwei || '')+ '</td>'+
															'<td width="10%" style="font-size:10px;text-align:center;">'+this.mxyingshouje.toFixed(2)+'</td>'+
															'<td width="18%" style="font-size:10px;text-align:center;'+yibaobz+'" '+yibaobz+'><span class="zilifei" style="padding-right:10px;">'+(parseFloat(this.mxzifeizlje || 0).toFixed(2))+'</span><span class="beifenbi">'+(percentNum(parseFloat(this.mxzifeizlje),this.mxyingshouje) || 0)+'</span></td>'+
														'</tr>';
										}
										if(i == 17){
											printStr += '<tr><td width="100%"  colspan="3" style="font-size:10px;text-align:center;">商品较多仅显示部分</td></tr>';
										}
								    });
								}
								var xianjinzf;
								if (fapiaoxq.ybjsid == null) {
									xianjinzf = fapiaoxq.hejije;
								} else {
									xianjinzf = fapiaoxq.bencixjzf;
								}
								
								printStr += '</tbody>'+
								'</table>'+
							'</div>'+
							'<div class="clearfix" style="height:25px;">'+
    							'<ul style="margin:0;padding:0;">'+
									'<li style="list-style:none;float:left;margin-right:8px;height:25px;">合计：'+fapiaoxq.hejije.toFixed(2)+'</li>'+
									'<li style="list-style:none;float:left;margin-right:8px;height:25px;">应收：'+parseFloat(xianjinzf).toFixed(2)+'</li>'+
									'<li style="list-style:none;float:left;margin-right:8px;height:25px;">实收：'+parseFloat(fapiaoxq.shishouje).toFixed(2)+'</li>'+
									'<li style="list-style:none;float:left;margin-right:8px;height:25px;">找还：'+parseFloat(fapiaoxq.zhaolingje).toFixed(2)+'</li>'+
								'</ul>'+
							'</div>'+
							'<div class="mingxixx" style="font-size:8px;'+yibaobz+'">'+
								'<div>现金支付：'+parseFloat(fapiaoxq.bencixjzf || 0).toFixed(2)+'(其中自费：'+parseFloat(fapiaoxq.xianjinzfzf|| 0).toFixed(2)+'自理：'+parseFloat(fapiaoxq.xianjinzfzl|| 0).toFixed(2)+'自负：'+parseFloat(fapiaoxq.bencixjzfzfbf|| 0).toFixed(2)+')</div>'+
								'<div><span>本年支付：'+parseFloat(fapiaoxq.bennianzhzf|| 0).toFixed(2)+'</span><span style="margin-left:15px;">本年余额：'+parseFloat(fapiaoxq.bennianzhye|| 0).toFixed(2)+'</span></div>'+
								'<div><span>历年支付：'+parseFloat(fapiaoxq.linianzhzf|| 0).toFixed(2)+'</span><span style="margin-left:15px;">历年余额：'+parseFloat(fapiaoxq.linianzhye|| 0).toFixed(2)+'</span><span style="margin-left:15px;">自负：'+parseFloat(fapiaoxq.zifuje|| 0).toFixed(2)+'(其中历年账户：'+parseFloat(fapiaoxq.linianzhzfzfbf|| 0).toFixed(2)+')</span></div>'+
								'<div><span>基金支付：'+parseFloat(fapiaoxq.yibaojjzf|| 0).toFixed(2)+'</span><span style="margin-left:15px;">本次起付标准：'+parseFloat(fapiaoxq.bencixjzf|| 0).toFixed(2)+'</span><span>起付标准累计：'+parseFloat(fapiaoxq.bennianmzqfbzzflj|| 0).toFixed(2)+'</span></div>'+
								'<div><span>自费：'+parseFloat(fapiaoxq.zifeije|| 0).toFixed(2)+'(其中历年账户：'+parseFloat(fapiaoxq.linianzhzfzf|| 0).toFixed(2)+')</span><span style="margin-left:15px;">自理：'+parseFloat(fapiaoxq.zilije|| 0).toFixed(2)+'(其中历年账户：'+parseFloat(fapiaoxq.linianzhzfzl|| 0).toFixed(2)+')</span></div>'+
							'</div>'+
						'</div>'+
					'</div>';
	obj.printArea(printStr);
}
// 百分比转化
function percentNum(num,num2) { 
return (Math.round(num / num2 * 10000) / 100.00 + "%"); //小数点后两位百分比
}
//核拨表打印
function printHebob(msg,obj){
	var date = new Date();
	var hebob = '';
	$.ajax({
		url : './hebob/getHebob',
		type : 'post',
		data : msg,
		async:false,
		success : function(data){
			hebob = data;
		}
	});
	var renshu = 0;
	var yiliaofeize = 0;
	var zilizf = 0;
	var liezhiylf = 0;
	var shenqingbf = 0;
	var src = '';
	src +='<div class="hebobiao-title" style="text-align: center;font-family:Microsoft Yahei,Serif;width:255mm;font-weight:700;color:#777;margin-bottom:30px;font-size:24px;">'+
				'<div class="hebobiao-title-main" style="font-family:Microsoft Yahei,Serif;">'+msg.title+'</div>'+
				'<div id="hebobiao-time" class="hebobiao-title-time">'+date.getFullYear()+'年'+date.getMonth()+1+'月'+'</div>'+
			'</div>'+
			'<div id="table_hebob" class="table-list">'+	
				'<div id="" class="">'+
					'<sapn id="heboblx" style="color:#777;font-size:16px;">定点医疗机构名称（盖章）：'+getZhensuomc()+'</sapn>'+
					'<div id="yiliaojgbh" class="hebb-out-yljgbh" style="float:right;font-size:16px;">医疗机构编号：'+getYiliaojgbh()+'</div>'+
		        '</div>'+			
		        '<div class="table-title s-title" style="border-bottom:0;padding-top:10px;width:255mm;">'+		
		        	'<table width="100%" cellpadding="0" border="0" cellspacing="0" style="table-layout: fixed;border-collapse: collapse;">'+	
				        '<thead>'+
				            '<tr>'+
					           '<th width="12%" style="border:solid 1px #ccc;padding:0 8px;line-height:30px;">险种</th>'+  
					           '<th width="15%" style="border:solid 1px #ccc;padding:0 8px;line-height:30px;">类别</th>'+      
					           '<th width="10%" style="border:solid 1px #ccc;padding:0 8px;line-height:30px;">人次数</th>'+          
					           '<th width="13%" style="border:solid 1px #ccc;padding:0 8px;line-height:30px;">医疗费总额</th>'+          
					           '<th width="13%" style="border:solid 1px #ccc;padding:0 8px;line-height:30px;">自理自费</th>'+          
					           '<th width="20%" style="border:solid 1px #ccc;padding:0 8px;line-height:30px;">定额考核列表支医疗费</th>'+          
					           '<th width="13%" style="border:solid 1px #ccc;padding:0 8px;line-height:30px;">申请拨付</th>'+          
					         '</tr>'+            
					     '</thead>'+               
					     '<tbody id="yibao-tbody3">';
							$.each(hebob,function(i,v){
								renshu += v.renshu;
								yiliaofeize += v.sum_yiliaofeize;
								zilizf += v.sum_zilizf;
								liezhiylf += v.sum_liezhiylf;
								shenqingbf += v.sum_shenqingbf;
								
								var xianzhong = '';
								if(v.xianzhong === 1){
									xianzhong = '职工医保';
								}
						     	src+='<tr>'+
					     		'<td style="border:solid 1px #ccc;padding:0 8px;line-height:30px;text-align: center;">'+xianzhong+'</td>'+
					     		'<td style="border:solid 1px #ccc;padding:0 8px;line-height:30px;text-align: center;">'+v.yiliaolb+'</td>'+
					     		'<td style="border:solid 1px #ccc;padding:0 8px;line-height:30px;text-align: center;">'+v.renshu+'</td>'+
					     		'<td style="border:solid 1px #ccc;padding:0 8px;line-height:30px;text-align: right;">'+v.sum_yiliaofeize.toFixed(2)+'</td>'+
					     		'<td style="border:solid 1px #ccc;padding:0 8px;line-height:30px;text-align: right;">'+v.sum_zilizf.toFixed(2)+'</td>'+
					     		'<td style="border:solid 1px #ccc;padding:0 8px;line-height:30px;text-align: right;">'+v.sum_liezhiylf.toFixed(2)+'</td>'+
					     		'<td style="border:solid 1px #ccc;padding:0 8px;line-height:30px;text-align: right;">'+v.sum_shenqingbf.toFixed(2)+'</td>'+
					     		'</tr>';
							});
					     	src+='<tr>'+

					     		'<td style="border:solid 1px #ccc;padding:0 8px;line-height:30px;text-align: center;">合计</td>'+
					     		'<td style="border:solid 1px #ccc;padding:0 8px;line-height:30px;text-align: center;"></td>'+
					     		'<td style="border:solid 1px #ccc;padding:0 8px;line-height:30px;text-align: center;">'+renshu+'</td>'+
					     		'<td style="border:solid 1px #ccc;padding:0 8px;line-height:30px;text-align: right;">'+yiliaofeize.toFixed(2)+'</td>'+
					     		'<td style="border:solid 1px #ccc;padding:0 8px;line-height:30px;text-align: right;">'+zilizf.toFixed(2)+'</td>'+
					     		'<td style="border:solid 1px #ccc;padding:0 8px;line-height:30px;text-align: right;">'+liezhiylf.toFixed(2)+'</td>'+
					     		'<td style="border:solid 1px #ccc;padding:0 8px;line-height:30px;text-align: right;">'+shenqingbf.toFixed(2)+'</td>'+
				     		'</tr>';	
					     	src+='</tbody>'+         
					  '</table>'+            
				'</div>'+            
				'<div class="hebb-out-extra clearfix" style="margin-top:10px;">'+            
					'<span class="hebb-out-extra-key" style="width:40%;float:left;">负责人：<span class="hebb-out-extra-fuzr"></span></span>'+        
					'<span class="hebb-out-extra-key" style="width:33%;text-align: center;">制表人：'+getDengluyg()+'<span></span class="hebb-out-extra-zhibr"></span>'+       	
					'<span class="hebb-out-extra-key" style="float:right;text-align:right;width:33%;">制表时间：<span id="zhibiaosj" class="hebb-out-extra-zhibsj">'+date.getFullYear()+'-'+date.getMonth()+1+'-'+date.getDate()+'</span></span>'+        	
				 '</div>'+       	
			'</div>';
					     	
	obj.printArea(src);
}

//获取本地日期      TODO   后期是否更换为数据库时间  ===待定
function getNowFormatDate() {
    var date = new Date();
    var seperator1 = "-";
    var year = date.getFullYear()+2;
    var month = date.getMonth() + 1;
    var strDate = date.getDate();
    if (month >= 1 && month <= 9) {
        month = "0" + month;
    }
    if (strDate >= 0 && strDate <= 9) {
        strDate = "0" + strDate;
    }
    var currentdate = year + seperator1 + month + seperator1 + strDate;
    return currentdate;
}

var ZIDONGJK = '';

//获得自动建库开关权限
function getZidongjk(zidongjk){
	ZIDONGJK = zidongjk;
}

var shouyaoflag;
var shouyaotsflag;
//字典耗材+药品结合查询(包括诊所和平台)
function getZdYaopinAndHaocai(obj,yewulx){
	var val = $(obj).val();
	var str = '';
	if(val != '') {
		clearTimeout(shouyaoflag);
		clearTimeout(shouyaotsflag);
		var flag = false;
		var reg = /[a-zA-Z1-9]/;
		if(reg.test(val)&&val.length==1) {
			$(obj).parent().find('ul').html("");
			flag = true;
			shouyaotsflag = setTimeout(function(){
				notifyInfo('与'+val+'匹配的信息过多，提供更多的检索信息系统将继续为您查找。');
			},1000);
		}
		if(flag) {
			return false;
		}
		shouyaoflag = setTimeout(function(){
			if(isTiaoxingma(val)=='true') {//扫码开药
				$(".f-input-li").css("display","none");
				$(obj).parent().parent().find('input:text,input:hidden').val('').removeAttr('readonly').removeClass("n-invalid");
				$(obj).parent().parent().find('.spanBaozhuanggg').addClass('guige-color').text('包装规格');
				$(obj).parent().parent().find('#shangpinlx').text('（未设置）');
				$(obj).parent().parent().find('#shangpinjx').text('（未设置）');
				$(obj).parent().parent().find('#shangpinbzgg').text('（未设置）');
				$(obj).parent().parent().find('#shangpinsccj').text('（未设置）');
				$(obj).parent().parent().find('.spanKaiyaodw').text('');
				$(obj).parent().parent().find(".sy-td-warning").css("display","none");
				$(obj).parent().parent().find(".sy-td-danger").css("display","none");
				$.ajax({
		    		url: path+'/zidian/getShangpingByTxm',
		    		type: 'post',
		    		data: {tiaoxingma:val,leixing:0},
		    		async: false,
		    		success: function(data) {
		    			console.log(data)
		    			if(data.length == 1) {
		    				xuanzeypFlag = true;
		    				var iszs = data[0].iszs;
		    				var id = data[0].id;
		    				var flag;
	    					$(obj).parent().parent().addClass('notComprareThis');//给当前行加上一个标记
	    					$(obj).parent().parent().parent().find('[name="zsShangpinid"]').each(function () {
	    						if(!$(this).hasClass('notComprareThis')) {//当前行不比较
	    							if(iszs == 0&& data[0].id == $(this).val()){
	    								notifyWarning('请不要添加重复商品');
	    								flag = true;
	    								return false;
	    							}
	    						}
	    					});
	    					$('#xsShangpinrkdmxtab').find('[name="zsShangpinid"]').each(function(){
	    						if(iszs==0 && data[0].id==$(this).val()){
	    							notifyWarning('请不要添加重复药品');
	    							flag = true;
	    							return false;
	    						}
	    					})
	    					$(obj).parent().parent().parent().find('[name="ptShangpinid"]').each(function(){
	    						if(!$(this).hasClass('notComprareThis')) {
	    							if(iszs==1 && data[0].id==$(this).val()){
	    								notifyWarning('请不要添加重复商品');
	    								flag = true;
	    								return false;
	    							}
	    						}
	    					});
	    					$(obj).parent().parent().parent().find('.chailingbz').val(data[0].chailingbz);
	    					$(obj).parent().parent().parent().find('.chailingsl').val(data[0].chailingsl);
	    					if(flag) {return false;}
	    					$(obj).parent().parent().removeClass('notComprareThis');
	    					if(data[0].baozhuangdw==null||data[0].baozhuangdw==''||data[0].baozhuangdw=='null') {
	    						$(obj).parent().parent().find('.sy-td-danger').css('display','block');
	    						$(obj).parent().parent().find('.sy-td-danger').attr('data-content','该商品不在库存并且缺少单位信息，请到【药品/耗材库存】中维护信息');
	    					}
		    				if(iszs==0) {
		    					$(obj).parent().parent().find('[name="zsShangpinid"]').val(data[0].id);
		    					$(obj).parent().parent().find('[name="ptShangpinid"]').val('');
		    					
		    					if(data[0].bieming!='null'&&data[0].bieming!=''&&data[0].bieming!=null) {
			    					$(obj).parent().find('.yaopinmc').val(data[0].bieming);
			    				}else{
			    					$(obj).parent().find('.yaopinmc').val(data[0].mingcheng);
			    				}
			    				$(obj).parent().parent().find('[name="iszs"]').val(iszs);
	    						if(data[0].chaxunlx == 0) {
	    							$(obj).parent().parent().find('[name="leixing"]').val(0);
	    						}else {
	    							$(obj).parent().parent().find('[name="leixing"]').val(1);
	    						}
			    				
			    				$(obj).parent().parent().find('[name="yaopinlx"]').val(data[0].leixing);
			    				
			    				if(data[0].morenkyl!=null&&data[0].morenkyl!='') {
			    					$(obj).parent().parent().find('[name="kaiyaoliang"]').val(data[0].morenkyl);
			    				}
			    				if(data[0].chailingbz == 1) {
			    					$(obj).parent().parent().find('[name="kaiyaodw"]').val(data[0].chailingdw);
			    				}else{
			    					$(obj).parent().parent().find('[name="kaiyaodw"]').val(data[0].baozhuangdw);
			    				}
			    				if(data[0].xiaoshoujia!=null&&data[0].xiaoshoujia!='') {
			    					$(obj).parent().parent().find('[name="danjia"]').val(data[0].xiaoshoujia);
			    					$(obj).parent().parent().find('[name="danjia"]').attr('readOnly','true');
			    				}
			    				$(obj).parent().parent().find('.spanBaozhuanggg').text(data[0].baozhuanggg).removeClass("guige-color");
			    				$(obj).parent().parent().parent().find('[name="tiaoxingma"]').val(data[0].tiaoxingma);
		    				}else{
		    					
		    					if(ZIDONGJK == 'true' || yewulx == 0){
		    						$(obj).parent().parent().find('[name="zsShangpinid"]').val('');
		    						$(obj).parent().parent().find('[name="ptShangpinid"]').val(data[0].id);
		    						if(data[0].bieming!='null'&&data[0].bieming!=''&&data[0].bieming!=null) {
		    							$(obj).parent().find('.yaopinmc').val(data[0].bieming);
		    						}else{
		    							$(obj).parent().find('.yaopinmc').val(data[0].mingcheng);
		    						}
		    						$(obj).parent().parent().find('[name="iszs"]').val(iszs);
		    						if(data[0].chaxunlx == 0) {
		    							$(obj).parent().parent().find('[name="leixing"]').val(0);
		    						}else {
		    							$(obj).parent().parent().find('[name="leixing"]').val(1);
		    						}
		    						
		    						$(obj).parent().parent().find('[name="yaopinlx"]').val(data[0].leixing);
		    						
		    						if(data[0].morenkyl!=null&&data[0].morenkyl!='') {
		    							$(obj).parent().parent().find('[name="kaiyaoliang"]').val(data[0].morenkyl);
		    						}
		    						if(data[0].chailingbz == 1) {
		    							$(obj).parent().parent().find('[name="kaiyaodw"]').val(data[0].chailingdw);
		    						}else{
		    							$(obj).parent().parent().find('[name="kaiyaodw"]').val(data[0].baozhuangdw);
		    						}
		    						if(data[0].xiaoshoujia!=null&&data[0].xiaoshoujia!='') {
		    							$(obj).parent().parent().find('[name="danjia"]').val(data[0].xiaoshoujia);
		    							$(obj).parent().parent().find('[name="danjia"]').attr('readOnly','true');
		    						}
		    						$(obj).parent().parent().find('.spanBaozhuanggg').text(data[0].baozhuanggg).removeClass("guige-color");
		    						$(obj).parent().parent().parent().find('[name="tiaoxingma"]').val(data[0].tiaoxingma);
		    					}
		    					$(obj).parent().parent().parent().find('.danhedw').text(data[0].baozhuangdw);
		    					$(obj).parent().parent().parent().find('.chufangdw').text(data[0].baozhuangdw);
		    					$(obj).parent().parent().parent().find('[name="danwei"]').val(data[0].baozhuangdw);
		    				}
		    				var chailingbz = data[0].chailingbz;
		    				if(chailingbz==0) {//不支持拆零spanKaiyaodw
		    					var strli = '';
		    					if(data[0].baozhuangdw!=null&&data[0].baozhuangdw!='') {
		    						$(obj).parent().parent().find('.spanKaiyaodw').text(data[0].baozhuangdw);
		    						$(obj).parent().parent().find('[name="kaiyaodw"]').attr('readOnly','readOnly');
		    						//strli += '<li>'+data[0].baozhuangdw+'</li>';
		    					}else{
		    						strli +='<li>盒</li>'+
		    								'<li>瓶</li>'+
		    								'<li>支</li>'+
		    								'<li>袋</li>'+
		    								'<li>丸</li>'+
		    								'<li>片</li>';
		    					}
		    					$(obj).parent().parent().find('.kaiyaodw').html("");
		    					$(obj).parent().parent().find('.kaiyaodw').html(strli);
		    				}else{
		    					$(obj).parent().parent().find('.spanKaiyaodw').text(data[0].chailingdw);
		    					var strli = '<li>'+data[0].baozhuangdw+'</li>'+'<li>'+data[0].chailingdw+'</li>';
		    					$(obj).parent().parent().find('[name="kaiyaodw"]').attr('readOnly','readOnly').css('background-color','#fff');
		    					$(obj).parent().parent().find('.kaiyaodw').html("");
		    					$(obj).parent().parent().find('.kaiyaodw').html(strli);
		    				}
		    				$('[name="kaiyaoliang"]').trigger('keyup');
		    				$(obj).blur();
		    				//扫码开药光标事件
	    					$(obj).parent().parent().parent().find("input:visible:not('.wm-group')").each(function(){
	    						if($(this).val()==""){
	    							$(this).focus();
	    							return false;
	    						}
	    					});
	    					if(yewulx == 0){// 从商品入库
	    						if(!(iszs ==1 && ZIDONGJK == "false")){
	    							$(obj).parent().parent().next(".rukusp-fujiaxx").css("display","table-row");
	    							if(data[0].bieming!='null'&&data[0].bieming!=''&&data[0].bieming!=null) {
	    								$(obj).parent().find('[name="shangpinmc"]').val(data[0].bieming);
	    							}else{
	    								$(obj).parent().find('[name="shangpinmc"]').val(data[0].mingcheng);
	    							}
	    							if(data[0].morenkydw!=null&&data[0].morenkydw!=''&&data[0].morenkydw!='单位') {
	    								$(obj).parent().parent().find('.danhedw').text(data[0].morenkydw);
	    								$(obj).parent().parent().find('[name="danwei"]').val(data[0].morenkydw);
	    							}else if(data[0].leixing==1){// 不在库饮片，默认单位为克
	    								$(obj).parent().parent().find('.danhedw').text(data[0].baozhuangdw);
	    								$(obj).parent().parent().find('[name="danwei"]').val(data[0].baozhuangdw);
	    								$(obj).parents('tr').find('.rukusp-deadtime').val(getNowFormatDate());
	    							}else{
	    								$(obj).parent().parent().find('.danhedw').text(data[0].baozhuangdw);
	    								$(obj).parent().parent().find('[name="danwei"]').val(data[0].baozhuangdw);
	    							}
	    							if(chailingbz==0){
	    								$(obj).parent().parent().find('.chufangdw').text(data[0].baozhuangdw);
	    							}else{
	    								$(obj).parent().parent().find('.chufangdw').text(data[0].chailingdw);
	    							}
	    							$(obj).parent().parent().find('.danhedw').text(data[0].baozhuangdw);
	    							if(data[0].jinhuojia!=null&&data[0].jinhuojia!='') {
	    								$(obj).parent().parent().find('[name="jinhuojia"]').val(data[0].jinhuojia.toFixed(2));
	    							}
	    							if(data[0].xiaoshoujia!=null&&data[0].xiaoshoujia!='') {
	    								$(obj).parent().parent().find('[name="xiaoshoujia"]').val(data[0].xiaoshoujia.toFixed(2));
	    							}
	    							
	    							$(obj).parent().parent().find("#shangpinlx").text(convertYaopinlx(data[0].leixing) || '(未设置)').css('color','#777');
	    							$(obj).parent().parent().find("#shangpinbzgg").text(data[0].baozhuanggg || '(未设置)').css('color','#777');
	    							$(obj).parent().parent().find("#shangpinjx").text(data[0].jixing || '(未设置)').css('color','#777');
	    							$(obj).parent().parent().find("#shangpinsccj").text(data[0].shengchancj || '(未设置)').css('color','#777');
	    							
	    							if(data[0].chaxunlx == 0) {
	    								$(obj).parent().parent().next().find(".shangpinlx").text(convertYaopinlx(data[0].leixing));
	    							}else {
	    								$(obj).parent().parent().next().find(".shangpinlx").text('耗材');
	    							}
	    							if(data[0].uuid!='' &&data[0].uuid!=null) {
	    								$(obj).parent().parent().find(".sy-td-warning").css("display","block");
	    								$(obj).parent().parent().find('.sy-td-warning').attr('data-content','该商品不在您的诊所库存中');
	    							}
	    						}
	    					}else if(yewulx == 1){
	    						$(".rukusp-fujiaxx").css("display","none");
	    					}
	    					yanhouzhsj = true;
	    					$(obj).trigger('focusout');
		    				return false;
		    			}else{//商品超过一条
							var IszsMark1 = 0;
							var IszsMark2 = 0;
							var str = '';
		    				$(data).each(function(){
		    					var shengchancj = this.shengchancj;
								var baozhuanggg = this.baozhuanggg;
								if(baozhuanggg!=null) {
									if(baozhuanggg.length>10) {
										baozhuanggg = baozhuanggg.substring(0,35)+'...';
									}
									baozhuanggg = '&nbsp;&nbsp;&nbsp;'+ baozhuanggg;
								}else{
									baozhuanggg = '';
								}
								if(shengchancj == null) {
									shengchancj = "";
								}
								if(this.iszs==0) {
									if(IszsMark1==0) {
										str+= '<span>当前在库商品</span>';
										IszsMark1++;
									}
								}
								if(this.iszs==1) {
									if(IszsMark2==0) {
										str+= '<span class="comm-dropm-span">以下商品均不在您的库存中</span>';
										IszsMark2++;
									}
								}
									//chaxunlx 0药品1耗材
									var chaxunlx = this.chaxunlx
									if(chaxunlx == 0){
										if(this.bieming !=''&&this.bieming !=null) {
											var xianshi = this.bieming+baozhuanggg+'&nbsp;&nbsp;&nbsp;' +shengchancj ;
										}else{
											var xianshi = this.mingcheng+baozhuanggg+'&nbsp;&nbsp;&nbsp;' +shengchancj ;
										}
										str+='<li class="xuanzeli" yaopinlx="'+this.leixing+'" iszs="'+this.iszs+'" leixing="0" index="'+this.id+'" uuid="'+this.uuid+'" >'+xianshi+'</li>';
									}else{
										var xianshi = this.mingcheng+baozhuanggg+'&nbsp;&nbsp;&nbsp;' +shengchancj ;
										str+='<li class="xuanzeli" iszs="'+this.iszs+'" leixing="1" index="'+this.id+'" uuid="'+this.uuid+'" >'+xianshi+'</li>';
									}
		    				});
		    			}
		    			$(obj).parent().find('ul').html("");
						$(obj).parent().find('ul').append(str).css('display','block');// ul不显示增加2017/2/4
		    		}
		    	});
			}else{
				$.ajax({
					url:path+'/zidian/getZdYaopinAndHaocai',
					type:'post',
					data:{mingcheng:val},
					success:function(data) {
						if(data!='') {
							var IszsMark1 = 0;
							var IszsMark2 = 0;
							var index = 0;
							$(data).each(function(){
								var shengchancj = this.shengchancj;
								var baozhuanggg = this.baozhuanggg;
								if(baozhuanggg!=null) {
									if(baozhuanggg.length>10) {
										baozhuanggg = baozhuanggg.substring(0,35)+'...';
									}
									baozhuanggg = '&nbsp;&nbsp;&nbsp;'+ baozhuanggg;
								}else{
									baozhuanggg = '';
								}
								if(shengchancj == null) {
									shengchancj = "";
								}
								var xianshi = this.mingcheng+baozhuanggg+'&nbsp;&nbsp;&nbsp;' +shengchancj ;
								if(this.iszs==0) {
									if(IszsMark1==0) {
										str+= '<span>当前在库商品</span>';
										IszsMark1++;
									}
									index++;
									str+='<li class="xuanzeli" yaopinlx="'+this.yaopinlx+'" iszs="'+this.iszs+'" leixing="'+this.leixing+'" index="'+this.id+'" uuid="'+this.uuid+'" >'+xianshi+'</li>';
								}
									if(this.iszs==1) {
										if(IszsMark2==0) {
											str+= '<span class="comm-dropm-span">以下商品均不在您的库存中</span>';
											IszsMark2++;
										}
										index++;
										str+='<li class="xuanzeli" yaopinlx="'+this.yaopinlx+'" iszs="'+this.iszs+'" leixing="'+this.leixing+'" index="'+this.id+'" uuid="'+this.uuid+'" >'+xianshi+'</li>';
									}
							});
						}
						if(index >= 10){
							str+='<li id="jingqueczsp" style="text-align:right;color:#00b472;padding-right:15px;">查看所有商品信息&gt;&gt;</li>';
						}
						$(obj).parent().find('ul').html("");
						$(obj).parent().find('ul').append(str);
					}
				});
			}
		},200);
	}else{
		$(obj).parent().parent().find("input").val("");
		$(obj).parent().parent().find("[name='danjia']").removeAttr('readOnly');
		$(obj).parent().parent().find("[name='jine']").removeAttr('readOnly');
		$(obj).parent().parent().find(".spanBaozhuanggg").text("");
		$(obj).parent().parent().find(".spanKaiyaodw").text("");
		$(obj).parent().parent().find(".sy-td-warning").css("display","none");
		$(obj).parent().parent().find(".sy-td-danger").css("display","none");
	}
}
// 数字转中文数字
function ChinaCost(numberValue){
	var numberValue=new String(Math.round(numberValue*100)); // 数字金额
	var chineseValue=""; // 转换后的汉字金额
	var String1 = "零壹贰叁肆伍陆柒捌玖"; // 汉字数字
	var String2 = "万仟佰拾亿仟佰拾万仟佰拾元角分"; // 对应单位
	var len=numberValue.length; // numberValue 的字符串长度
	var Ch1; // 数字的汉语读法
	var Ch2; // 数字位的汉字读法
	var nZero=0; // 用来计算连续的零值的个数
	var String3; // 指定位置的数值
	if(len>15){
	return "";
	}
	if (numberValue==0){
	chineseValue = "零元整";
	return chineseValue;
	}
	String2 = String2.substr(String2.length-len, len); // 取出对应位数的STRING2的值
	for(var i=0; i<len; i++){
	String3 = parseInt(numberValue.substr(i, 1),10); // 取出需转换的某一位的值
	if ( i != (len - 3) && i != (len - 7) && i != (len - 11) && i !=(len - 15) ){
	if ( String3 == 0 ){
	Ch1 = "";
	Ch2 = "";
	nZero = nZero + 1;
	}
	else if ( String3 != 0 && nZero != 0 ){
	Ch1 = "零" + String1.substr(String3, 1);
	Ch2 = String2.substr(i, 1);
	nZero = 0;
	}
	else{
	Ch1 = String1.substr(String3, 1);
	Ch2 = String2.substr(i, 1);
	nZero = 0;
	}
	}
	else{ // 该位是万亿，亿，万，元位等关键位
	if( String3 != 0 && nZero != 0 ){
	Ch1 = "零" + String1.substr(String3, 1);
	Ch2 = String2.substr(i, 1);
	nZero = 0;
	}
	else if ( String3 != 0 && nZero == 0 ){
	Ch1 = String1.substr(String3, 1);
	Ch2 = String2.substr(i, 1);
	nZero = 0;
	}
	else if( String3 == 0 && nZero >= 3 ){
	Ch1 = "";
	Ch2 = "";
	nZero = nZero + 1;
	}
	else{
	Ch1 = "";
	Ch2 = String2.substr(i, 1);
	nZero = nZero + 1;
	}
	if( i == (len - 11) || i == (len - 3)){ // 如果该位是亿位或元位，则必须写上
	Ch2 = String2.substr(i, 1);
	}
	}
	chineseValue = chineseValue + Ch1 + Ch2;
	}
	if ( String3 == 0 ){ // 最后一位（分）为0时，加上“整”
	chineseValue = chineseValue + "整";
	}
	return chineseValue;
}





